import com.fasterxml.jackson.annotation.JacksonAnnotationValue;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ScrollType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import kotlinx.datetime.Clock;
import org.jetbrains.annotations.NotNull;
import org.mozilla.javascript.NativeConsole;



import java.util.Random;
import java.security.SecureRandom;

import java.io.*;
import java.net.*;


import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
//import com.intellij.ide;

public class ChangeDebugModeAction extends AnAction {
    
    @Override
    public void actionPerformed(@NotNull AnActionEvent event) {
        // 执行操作时显示对话框
        //Messages.showInfoMessage("Hello from Custom Action---ChangeDebugModeAction!", "Plugin Action");

        // Get all the required data from data keys
        Editor editor = event.getData(CommonDataKeys.EDITOR);
        if (editor == null) {

            if (Constants.debug_mode) {
                Constants.debug_mode = false;
                Messages.showInfoMessage("QBS04: Debug mode is off!", "Plugin Action");

            } else {
                Constants.debug_mode = true;
                Messages.showInfoMessage("QBS04: Debug mode is open!", "Plugin Action");
                //System.out.println("now true.");
            }
        }
  }
    
    @Override
    public void update(@NotNull AnActionEvent e) {
        // 根据上下文启用或禁用Action
        // 例如：只有在有项目打开时才启用
        boolean hasProject = e.getProject() != null;
        e.getPresentation().setEnabled(hasProject);
    }
    
    @Override
    public @NotNull ActionUpdateThread getActionUpdateThread() {
        // 在事件调度线程上执行update方法
        return ActionUpdateThread.EDT;
    }
}











